package com.ldkj.panzh.controller;

import com.ldkj.panzh.domain.AjaxResult;
import com.ldkj.panzh.domain.TableDataInfo;
import com.ldkj.panzh.param.BarrierGateParam;
import com.ldkj.panzh.param.MonitoringPointParam;
import com.ldkj.panzh.param.MonitoringPointDeviceParam;
import com.ldkj.panzh.service.BarrierGateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 道闸（园区卡口）控制器
 *
 * @author qiancheng
 * @date 2025-11-19
 */
@Controller
public class BarrierGateController extends BaseController {

    @Autowired
    BarrierGateService barrierGateService;

    /**
     * 查询道闸列表
     *
     * @param barrierGateParam 查询参数
     * @return 道闸列表数据
     * @throws Exception
     */
    @RequestMapping("/queryBarrierGates")
    @ResponseBody
    public TableDataInfo queryBarrierGates(@RequestBody BarrierGateParam barrierGateParam) throws Exception {
        return getDataTable(barrierGateService.queryBarrierGates(barrierGateParam));
    }

    /**
     * 查询道闸数量和状态统计
     *
     * @param barrierGateParam 查询参数
     * @return 统计数据（总数、在线数、离线数、开启数、关闭数、异常数等）
     * @throws Exception
     */
    @RequestMapping("/queryBarrierGateStats")
    @ResponseBody
    public AjaxResult queryBarrierGateStats(@RequestBody BarrierGateParam barrierGateParam) throws Exception {
        return success(barrierGateService.queryBarrierGateStats(barrierGateParam));
    }

    /**
     * 查询园区卡口（监控点）列表
     * 对应API: /api/resource/v1/monitoringPoint/search
     *
     * @param monitoringPointParam 查询参数
     * @return 园区卡口列表数据
     * @throws Exception
     */
    @RequestMapping("/api/resource/v1/monitoringPoint/search")
    @ResponseBody
    public TableDataInfo searchMonitoringPoints(@RequestBody MonitoringPointParam monitoringPointParam) throws Exception {
        return getDataTable(barrierGateService.searchMonitoringPoints(monitoringPointParam));
    }

    /**
     * 查询园区卡口设备列表
     * 对应API: /api/resource/v1/monitoringPointDevice/search
     *
     * @param monitoringPointDeviceParam 查询参数
     * @return 园区卡口设备列表数据
     * @throws Exception
     */
    @RequestMapping("/api/resource/v1/monitoringPointDevice/search")
    @ResponseBody
    public TableDataInfo searchMonitoringPointDevices(@RequestBody MonitoringPointDeviceParam monitoringPointDeviceParam) throws Exception {
        return getDataTable(barrierGateService.searchMonitoringPointDevices(monitoringPointDeviceParam));
    }
}
